package demo.ybt;

import java.util.Arrays;

public class P1233_2 {

    public static void main(String[] args) {
        P1233_2 p1233 = new P1233_2();
        p1233.res(new int[]{23, 71, 87, 32, 70, 93, 80, 76}, 4);
        //p1233.res(new int[]{4 ,4 ,1 ,2 ,1}, 3);
    }

    /**
     * m个 水龙头
     *
     * @param t
     * @param m
     * @return
     */
    public int res(int[] t, int m) {
        int[] store = new int[m];
        //Arrays.sort(t);
        int max = 0;
        for (int i = t.length - 1; i >= 0; i--) {
            Arrays.sort(store);
            store[0] += t[i];
            max = Math.max(store[0], max);
        }

        System.out.println(max);
        return max;
    }
}
